<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set an error handler for a XSLT processor</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-encoding.html">xslt_set_encoding</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-log.html">xslt_set_log</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.xslt-set-error-handler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xslt_set_error_handler</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4)</p><p class="refpurpose"><span class="refname">xslt_set_error_handler</span> &mdash; <span class="dc-title">Set an error handler for a <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> processor</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.xslt-set-error-handler-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>xslt_set_error_handler</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$xh</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$handler</code></span>
   )</div>

  <p class="para rdfs-comment">
   Set an error handler function for the <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> processor given by
   <em><code class="parameter">xh</code></em>, this function will be called whenever an
   error occurs in the <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> transformation (this function is also called
   for notices).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xslt-set-error-handler-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">
xh</code></em></dt>
<dd>
<p class="para"><acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> 处理器连接标识符，由
<span class="function"><a href="function.xslt-create.html" class="function">xslt_create()</a></span> 创建。</p></dd>


    
     <dt>
<em><code class="parameter">handler</code></em></dt>

     <dd>

      <p class="para">
       The user function needs to accept four parameters: the <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym> processor,
       the error level, the error code and an array of messages. The function
       can be shown as:
       <div class="methodsynopsis dc-description">
        <span class="methodname"><span class="replaceable">error_handler</span></span>
         ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$xh</code></span>
        , <span class="methodparam"><span class="type">int</span> <code class="parameter">$error_level</code></span>
        , <span class="methodparam"><span class="type">int</span> <code class="parameter">$error_code</code></span>
        , <span class="methodparam"><span class="type">array</span> <code class="parameter">$messages</code></span>
        )</div>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xslt-set-error-handler-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.xslt-set-error-handler-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-5435">
   <p><strong>Example #1 <span class="function"><strong>xslt_set_error_handler()</strong></span> Example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Our&nbsp;XSLT&nbsp;error&nbsp;handler<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">xslt_error_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$handler</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$level</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;for&nbsp;now,&nbsp;let's&nbsp;just&nbsp;see&nbsp;the&nbsp;arguments<br />&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">func_get_args</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;XML&nbsp;content&nbsp;:<br /></span><span style="color: #0000BB">$xml</span><span style="color: #007700">=</span><span style="color: #DD0000">'&lt;?xml&nbsp;version="1.0"?&gt;<br />&lt;para&gt;<br />&nbsp;oops,&nbsp;I&nbsp;misspelled&nbsp;the&nbsp;closing&nbsp;tag<br />&lt;/pata&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;XSL&nbsp;content&nbsp;:<br /></span><span style="color: #0000BB">$xsl</span><span style="color: #007700">=</span><span style="color: #DD0000">'&lt;?xml&nbsp;version="1.0"?&gt;<br />&lt;xsl:stylesheet&nbsp;version="1.0"&nbsp;xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;<br />&lt;xsl:template&nbsp;match="/"&gt;<br />&nbsp;&nbsp;&nbsp;&lt;strong&gt;&lt;xsl:value-of&nbsp;select="para"/&gt;&lt;/strong&gt;<br />&lt;/xsl:template&gt;<br />&lt;/xsl:stylesheet&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$xh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xslt_create</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">xslt_set_error_handler</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"xslt_error_handler"</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">xslt_process</span><span style="color: #007700">(</span><span style="color: #0000BB">$xh</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xml'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arg:/_xsl'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"/_xml"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$xml</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"/_xsl"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$xsl</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
  [0]=&gt;
  resource(1) of type (XSLT Processor)
  [1]=&gt;
  int(3)
  [2]=&gt;
  int(0)
  [3]=&gt;
  array(6) {
    [&quot;msgtype&quot;]=&gt;
    string(5) &quot;error&quot;
    [&quot;code&quot;]=&gt;
    string(1) &quot;2&quot;
    [&quot;module&quot;]=&gt;
    string(9) &quot;Sablotron&quot;
    [&quot;URI&quot;]=&gt;
    string(9) &quot;arg:/_xml&quot;
    [&quot;line&quot;]=&gt;
    string(1) &quot;4&quot;
    [&quot;msg&quot;]=&gt;
    string(34) &quot;XML parser error 7: mismatched tag&quot;
  }
}
</pre></div>
   </div>
  </div>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.xslt-set-error-handler-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.xslt-set-object.html" class="function" rel="rdfs-seeAlso">xslt_set_object()</a> - Sets the object in which to resolve callback functions</span> if you want to use an
     object method as handler</li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.xslt-set-encoding.html">xslt_set_encoding</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.xslt-set-log.html">xslt_set_log</a></div>
 <div class="up"><a href="ref.xslt.html">XSLT (PHP 4) 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
